<!DOCTYPE html>
<?php
include 'proses/konek.php';
session_start();
if(!isset($_SESSION['admin']))
   {   
  ?><script language="javascript">alert('anda blm login');
document.location='index.html'</script><?php 
}
else
{
$username = $_SESSION['admin'];
}
?>
<html lang="en">

<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">

    <title>KELAS</title>

    <!-- Bootstrap Core CSS -->
    <link href="css/bootstrap.min.css" rel="stylesheet">

    <!-- MetisMenu CSS -->
    <link href="css/plugins/metisMenu/metisMenu.min.css" rel="stylesheet">

    <!-- DataTables CSS -->
    <link href="css/plugins/dataTables.bootstrap.css" rel="stylesheet">

    <!-- Custom CSS -->
    <link href="css/sb-admin-2.css" rel="stylesheet">

    <!-- Custom Fonts -->
    <link href="font-awesome-4.1.0/css/font-awesome.min.css" rel="stylesheet" type="text/css">
    <script type="text/javascript">
    var ajaxku;
    function kelas(id){
     ajaxku = buatajax();
     var url="proses/select.php?kelas=1&&id="+id;
     ajaxku.onreadystatechange=idkelas;
     ajaxku.open("GET",url,true);
     ajaxku.send(null);
    }


    function buatajax(){ 
    if (window.XMLHttpRequest){ 
    return new XMLHttpRequest(); 
    } 
    if (window.ActiveXObject){ 
    return new ActiveXObject("Microsoft.XMLHTTP"); 
    } 
    return null; 
    } 

    function idkelas(){
    var data;
     if (ajaxku.readyState==4 && ajaxku.status==200){
     data=ajaxku.responseText;
     if(data.length>1){
       document.getElementById("class").innerHTML=data;
       
       
       }
       else
       {
       document.getElementById("class").innerHTML="";
       
       }
     }
    }
    
    </script>


</head>

<body>

<div class="modal fade" id="kelas">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <a class="close" data-dismiss="modal">&times;</a>
                    <h1 class="page-title">edit kelas</h1>
                   
                </div>
                <div class="modal-body">
                    <div class="panel-heading resume-heading">
                        <div class="row">
                          <div class="col-lg-12">
                            <form class="form-horizontal" role="form" action="proses/updatekelas.php" method="POST" id="class">
                                
                          </div>
                        </div>
                      </div>
                      
                </div>
                <div class="modal-footer">
                        
                        <button class="btn btn-primary" type="submit">update</button>
                </form>
                        
                </div>
            </div>
        </div>
    </div>
    <div id="wrapper">

        <!-- Navigation -->
        <nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
            <div class="navbar-header">
                <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
                    <span class="sr-only">Toggle navigation</span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                    <span class="icon-bar"></span>
                </button>
                <a class="navbar-brand" href="dashboard.php">Admin</a>
            </div>
            <!-- /.navbar-top-links -->

            <?php
            include 'proses/menustatic.php';
            $menustatic = new menustatic;
            $menustatic->menus();
             ?>
            <!-- /.navbar-static-side -->
        </nav>

        <div id="page-wrapper">
            <div class="row">
                <div class="col-lg-12">
                    <h1 class="page-header">Post Manager</h1>
                </div>
                <!-- /.col-lg-12 -->
            </div>
            <!-- /.row -->
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                            DAFTAR KELAS
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <div class="table-responsive">
                                <table class="table table-striped table-bordered table-hover" id="dataTables-example">
                                    <thead>
                                        <tr>
                                            <th>#</th>
                                            <th>KELAS</th>
					    <th>EDIT</th>
                                       </tr>
                                    </thead>
                                    <tbody>
									<?php
                                    $no=1;
									$query=mysql_query("select * from kelas");
									while($kelas=mysql_fetch_assoc($query))
									{
                                        echo "<tr class='odd gradeX'>
                                            <td>".$no."</td>
                                            <td>".$kelas['kelas']."</td>
                                            <td><button class='btn btn-success' href='#kelas' data-toggle='modal' value='".$kelas['id']."' onclick='kelas(this.value)'>UPDATE</button>/<a class='btn btn-danger' href='proses/kelas.php?stat=hapus&&id=".$kelas['id']."'>DELETE</a></td>
                                        </tr>";
                                        
									$no++;
                                    }

									?>
                                    </tbody>
                                </table>
                            </div>
                            <!-- /.table-responsive -->
                        </div>
                        <!-- /.panel-body -->
                    </div>
		    <div class="panel-body">
		   <form action="proses/kelas.php" method="post">
		   <lable><strong>TAMBAH KELAS</strong></lable>
		   <input type="text" name="kelas">
		   <button class="btn btn-success" name="tambah" type="submit">ADD</button>
		   </form>
		    </div>			
                    <!-- /.panel -->
                </div>	
                <!-- /.col-lg-12 -->
            </div>

        </div>
        <!-- /#page-wrapper -->
    </div>
    <!-- /#wrapper -->

    <!-- jQuery -->
    <script src="js/jquery.js"></script>

    <!-- Bootstrap Core JavaScript -->
    <script src="js/bootstrap.min.js"></script>

    <!-- Metis Menu Plugin JavaScript -->
    <script src="js/plugins/metisMenu/metisMenu.min.js"></script>

    <!-- DataTables JavaScript -->
    <script src="js/plugins/dataTables/jquery.dataTables.js"></script>
    <script src="js/plugins/dataTables/dataTables.bootstrap.js"></script>

    <!-- Custom Theme JavaScript -->
    <script src="js/sb-admin-2.js"></script>

    <!-- Page-Level Demo Scripts - Tables - Use for reference -->
    <script>
    $(document).ready(function() {
        $('#dataTables-example').dataTable();
			
    });
    </script>

</body>

</html>
